<%@page import="beans.Userbean"%>
<%@page import="dao.User"%>
<%@ page import="java.util.*" %>
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@taglib uri="/WEB-INF/tlds/pagediv" prefix="page" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
		<link href="../css/mytable.css" rel="stylesheet" type="text/css">
		<style type="text/css">

#outside {
	margin:0 auto;
	text-align:center;
}
</style>
		<title>显示所有用户</title>
		
	</head>
	<body>
		<div id="outside">
			<table id="mytable" >
				<caption>
					用户列表
				</caption>
				<tr>
					<th scope="col">
						用户编号
					</th>
					<th scope="col">
						用户名称
					</th>
					<th scope="col">
						用户密码
					</th>					
					<th scope="col">
						重置密码
					</th>
				</tr>
				<%
					Userbean userbean = new Userbean();
					request.setAttribute("counts",userbean.getUserCounts());
					request.setAttribute("pageSize",userbean.getPageCounts());
					List<User> list = (ArrayList<User>)request.getAttribute("data");
					if(list == null){
						list = userbean.getAllUsers(1);
						}
						if(list != null){
						
							StringBuffer buffer = null;
                            for (int i=0;i<list.size();i++) {
                        		buffer = new StringBuffer();
                        		buffer.append("<tr><td>").append(list.get(i).getUserid()).append("</td><td>")
                        		.append(list.get(i).getUsername())                       		
                        		.append("</td><td>")
                        		.append(list.get(i).getPassword())
                        		.append("</td><td><a href='../servlet/UserManageServlet?action=reset&userId=").append(list.get(i).getUserid())
                        		.append("'>重置密码</a></td></tr>");
                        		out.write(buffer.toString());
                            }
						 } else {
									out.println("<tr><td colspan='5'>目前没有满足要求的数据</td></tr>");
                         }
                        %>
			</table>
			<page:divide pageNum="${pageNum}" pageSize="${pageSize}" counts="${counts}"
                     url="../servlet/UserDividePageServlet">                
        </page:divide>
		</div>
		
	</body>
</html>